import 'dart:async';

import 'package:get/get.dart';

import '../../componentview/controllers/IndexViewController.dart';

class BindSucessController extends GetxController {

  Timer? _timer;

  @override
  void onInit() {
    super.onInit();
  }

  @override
  void onReady() {
    super.onReady();
    IndexViewController indexViewController = GetInstance().find<IndexViewController>();
    if (indexViewController != null) {
      indexViewController.freshBatteryPowAndWifi();
    }
    startTimer();
  }

  @override
  void onClose() {
    stopTimer();
    super.onClose();

  }

  void startTimer() {
    _timer = Timer.periodic(Duration(seconds: 2), (Timer timer) {
      IndexViewController indexViewController = GetInstance().find<IndexViewController>();
      if (indexViewController != null) {
        indexViewController.freshBatteryPowAndWifi();
      }


    });
  }

  void stopTimer() {
    _timer?.cancel();
    _timer = null;

  }

}
